package com.silences.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.rmi.ServerException;

//登录退出接口
@WebServlet("/buyerlogout") //设置接口路径
public class BuyerLogoutServlet extends HttpServlet {
    //extends 继承 HttpServlet类

    //get 请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
       doPost(req,resp);
    }


    //post 请求
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServerException,IOException {

        //在服务器中清除用户名
        req.getSession().removeAttribute("buyername");
        // 使用重定向，跳转登录页面
        resp.sendRedirect("/Test/home.jsp");

    }
}
